// pages/user/user/userPutIn/userPutIn.js
const app = getApp();
var util = require('../../../../utils/util.js');
import Api from '../../../../utils/http';
Page({

  /**
   * 页面的初始数据
   */
  data: {
    currMonth: '本月',
    chooseMonth: '', //选中的月份
    endMonth: util.formatMonth(new Date), //限制不可选取未来的月份
    dataList: [],
    datatext:'',
    code:null,  },
  //选择月份
  bindMonthChange: function (e) {
    console.log('picker发送选择改变，携带值为', e.detail.value)
    var chooseMonth = e.detail.value;
    if (chooseMonth == util.formatMonth(new Date)) {
      chooseMonth = '本月'
    }
    this.setData({
      currMonth: chooseMonth
    })
  },
  //跳转投放数据
  toPutInData: function () {
    wx.navigateTo({
      url: '/pages/user/user/userPutInData/userPutInData',
    })
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    var that = this;
    that.getPersonInfo();
    that.getBalanceList();
    
  },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {

  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {

  },
  
  //我的投放
  getBalanceList: function () {
    var that = this;
    let uid = wx.getStorageSync('userid')
    var param = {
      selType: 1,
      user_type: uid.user_type,
      uid: uid.id,
      pageNum: 1,
      pageSize: 9
    }
    console.log(param)
    Api.ajax("/app/Zmanage/balanceList", param).then(res => {
      console.log(res)
      if (res.code == 200) {
        that.setData({
          dataList: res.data,
          code:res.code
        });
      }else{
        that.setData({
          dataList: 0
        })
      }
    })
  },
  //头部数据
  getPersonInfo:function(){
    var that = this;
    let uid = wx.getStorageSync('userid')
    var param = {
      user_type: uid.user_type,
      uid: uid.id,
    }
    // console.log(param)
    Api.ajax("/app/Zindex/personInfo", param).then(res => {
      console.log(res)
      if (res.code == 200) {
        that.setData({
          datatext: res.data
        });
      }
    })
  },
  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function () {

  }
})